#!/bin/bash -e


while getopts  ":p:" opts
do
	case  $opts  in
	p) out_prefix=$OPTARG;;
	esac
done
shift $(($OPTIND - 1))

if [ -z "$2" ]; then
	echo 'summa.sh [-p out_prefix] <input.bam> <interval.bed>'
	exit 1
fi


. /mnt/ilustre/app/medical/tools/.var


# prefix=.depth

# summ_gatk.sh -p $prefix $1 $2
summ_gatk.sh $1 $2

cat $out_prefix.sample_summary |cut -d "," --complement -f 4-6 |sed -n '$d; s/,/\t/gp' > $out_prefix.summ.txt
cat $out_prefix.sample_gene_summary |cut -d "," --complement -f 2-3,6-8 |sed -n 's/,/\t/gp' > $out_prefix.gene_summ.txt

cat $out_prefix.sample_interval_summary |cut -d "," --complement -f 2-3,6-8 |sed -n 's/,/\t/gp' > $out_prefix.interval_summ.txt
# rm $prefix*

. $cmd_done